package com.example.service.impl;

//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mapper.GoodsMapper;
import com.example.pojo.entity.Goods;
import com.example.service.GoodsService;
import com.example.service.GoodsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Resource
    GoodsMapper goodsMapper;

    @Override
    public void insert(Goods goods) {
        goodsMapper.insert(goods);
    }

    @Override
    public void updateById(Goods goods) {
        goodsMapper.updateById(goods);
    }

    @Override
    public void removeById(Integer id) {
        goodsMapper.removeById(id);
    }

    @Override
    public void removeBatchByIds(List<Integer> ids) {
        for (Integer id : ids){
            goodsMapper.removeById(id);
        }
    }

    @Override
    public List<Goods> list() {
        List<Goods> list = goodsMapper.list();
        return list;
    }

    @Override
    public Goods getById(Integer id) {
        Goods goods = goodsMapper.getById(id);
        return goods;
    }

    @Override
    public PageInfo<Goods> selectByPage(Integer pageNum, Integer pageSize, String name, Integer state) {
        PageHelper.startPage(pageNum, pageSize);
        List<Goods> list = goodsMapper.selectByPage(name,state);
        return new PageInfo<>(list);
    }
}
